<include file="Public/head"/>
<body class="no-skin">
<include file="Public/header"/>
<div class="main-container" id="main-container">
    <script type="text/javascript">
        try {
            ace.settings.check('main-container', 'fixed')
        } catch (e) {
        }
    </script>
    <style type="text/css">
            
            #allmap{height:300px;width:600px;}
            #r-result{width:100%; font-size:14px;}
    </style>
    <script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=xH9CkRR96Vk6KWM2KH5qhlsSncNgAGdQ"></script>
    <include file="Public/sidebar"/>
    <div class="main-content">
        <div class="main-content-inner">
            <!-- #section:basics/content.breadcrumbs -->
            <include file="Public/breadcrumbs"/>

            <!-- /section:basics/content.breadcrumbs -->
            <div class="page-content">
                <include file="Public/set"/>

                <!-- /section:settings.box -->
                <div class="row">
                    <div class="col-xs-12">
                        <!-- PAGE CONTENT BEGINS -->
                        <form class="form-horizontal" action="{:U('update')}" method="post">
                            <div class="form-group">
                                <label class="col-sm-1 control-label no-padding-right" for="form-field-1"> 登录名 </label>
                                <div class="col-sm-9">
                                    <input type="text"
                                    <if condition="$member['uid'] eq 1">readonly
                                        <else/>
                                        name="user"
                                    </if>
                                    class="col-xs-2 col-sm-2"  value="{$member.user}">
                                    <input type="hidden" name="uid" value="{$member['uid']}">
                                    <span class="help-inline col-xs-12 col-sm-7">
											<if condition="$member['uid'] eq 1"><span class="middle">无法修改</span></if>
											</span>
                                </div>
                            </div>
                           
                               
                            <div class="space-4"></div>
                            <div class="form-group">
                                <label class="col-sm-1 control-label no-padding-right" for="form-field-1"> 教师名称 </label>
                                <div class="col-sm-9">
                                    <input type="text" name='name' class='col-xs-2 col-sm-2'  value="{$member['name']}">
                                   
                                </div>
                            </div>
                           
                               
                            <div class="space-4"></div>
                            <div class="form-group">
                                <label class="col-sm-1 control-label no-padding-right" for="form-field-10"> 用户组 </label>
                                <div class="col-sm-9">
                                    <if condition="$member['uid'] eq 1">
                                        <volist name="usergroup" id="val">
                                            <if condition="$val['id'] eq $member['group_id']">
                                                <input type="text" class="col-xs-10 col-sm-5" value="{$val['title']}"
                                                       readonly>
                                                <input type="hidden" name="group_id" id="group_id"
                                                       class="col-xs-10 col-sm-5" value="{$member['group_id']}">
                                            </if>
                                        </volist>

                                        <else/>
                                        <select id="group_id" name="group_id" class="col-xs-1 col-sm-1">
                                            <volist name="usergroup" id="val">
                                                <option value="{$val['id']}"
                                                <if condition="$val['id'] eq $member['group_id']">selected="selected"
                                                </if>
                                                >{$val['title']}</option>
                                            </volist>
                                        </select>
                                    </if>
                                    <span class="help-inline col-xs-12 col-sm-7">
												<span class="middle">请慎重选择用户组</span>
											</span>
                                </div>
                            </div>
                            <div class="space-4"></div>
                            <div class="form-group">
                                <label class="col-sm-1 control-label no-padding-right" for="form-field-6"> 教师类型 </label>
                                <div class="col-sm-9">
                                    <select name="teacher_type" class="col-xs-1 col-sm-1">
                                        <option>-请选择-</option>
                                        <option <if condition="$member['teacher_type'] eq 1"> selected="selected"</if> value="1">班主任</option>
                                        <option <if condition="$member['teacher_type'] eq 2"> selected="selected"</if> value="2">生活老师</option>
                                        <option <if condition="$member['teacher_type'] eq 3"> selected="selected"</if> value="3">配班老师</option>
                                        <option <if condition="$member['teacher_type'] eq 4"> selected="selected"</if> value="4">保健医生</option>
                                    </select>
                                            
                                </div>

                            </div>
                            <div class="space-4"></div>
                             <div class="form-group">
                                <label class="col-sm-1 control-label no-padding-right" for="form-field-6"> 所属班型 </label>
                                <div class="col-sm-9">
                                    <select name="class_id" class="col-xs-1 col-sm-1">
                                        <option>-请选择-</option>
                                        <foreach name="class_info" item="vo">
                                            <option <if condition="$vo['id'] eq $member['class_id']"> selected="selected"</if> value="{$vo.id}">{$vo.name}</option>
                                        </foreach>
                                    </select>
                                    <span class="help-inline col-xs-12 col-sm-7">
												<span class="middle">保健老师可不选所属班型</span>
											</span>
                                </div>
                            </div>
                            
                            <div class="space-4"></div>
                            <div class="form-group">
                                <label class="col-sm-1 control-label no-padding-right" for="form-field-2"> 用户密码 </label>
                                <div class="col-sm-9">
                                    <input type="password" name="password" id="password" placeholder="用户密码"
                                           class="col-xs-2 col-sm-2" value="">
                                    <span class="help-inline col-xs-12 col-sm-7">
												<span class="middle">留空不修改</span>
											</span>
                                </div>
                            </div>

                            <div class="space-4"></div>

                            <div class="form-group">
                                <label class="col-sm-1 control-label no-padding-right" for="form-field-4"> 头像 </label>
                                <div class="col-sm-9">
                                    <div class="col-xs-2 col-sm-2">{:UpImage("head",100,100,$member['head'])}</div>
                                    <span class="help-inline col-xs-12 col-sm-7">
												<span class="middle">仅支持jpg、gif、png、bmp、jpeg，且小于1MB。</span>
											</span>
                                </div>

                            </div>
                            
                            <div class="space-4"></div>

                            <div class="form-group">
                                <label class="col-sm-1 control-label no-padding-right" for="form-field-6"> 电话号码 </label>
                                <div class="col-sm-9">
                                    <input type="text" name="phone" id="phone" placeholder="电话号码"
                                           class="col-xs-2 col-sm-2" value="{$member['phone']}">
                                    <span class="help-inline col-xs-12 col-sm-7">
												<span class="middle"></span>
											</span>
                                </div>
                            </div>


                            <div class="space-4"></div>

                            <div class="form-group">
                                <label class="col-sm-1 control-label no-padding-right" for="form-field-8">
                                    E-mail </label>
                                <div class="col-sm-9">
                                    <input type="email" name="email" id="email" placeholder="E-mail"
                                           class="col-xs-2 col-sm-2" value="{$member['email']}">
                                    <span class="help-inline col-xs-12 col-sm-7">
												<span class="middle"></span>
											</span>
                                </div>
                            </div>
                            
                            	<!-- 简介 -->
                            <div class="space-4"></div>
                             <div class="form-group">
                                <label class="col-sm-1 control-label no-padding-right" for="form-field-2">
                                    	简介内容 </label>
                                <div class="col-sm-9">
                                        <textarea name="content" id="content"
                                                  style="width:50%;height:200px;visibility:hidden;">{$member['content']}</textarea>
                                </div>
                            </div>
                            	


                            <div class="space-4"></div>

                            <div class="col-md-offset-2 col-md-9">
                                <button class="btn btn-info" type="submit">
                                    <i class="icon-ok bigger-110"></i>
                                    提交
                                </button>

                                &nbsp; &nbsp; &nbsp;
                                <button class="btn" type="reset">
                                    <i class="icon-undo bigger-110"></i>
                                    重置
                                </button>
                            </div>
                        </form>
                        <!-- PAGE CONTENT ENDS -->
                    </div><!-- /.col -->
                </div><!-- /.row -->
            </div><!-- /.page-content -->
        </div>
    </div><!-- /.main-content -->
    <include file="Public/footer"/>

</div><!-- /.main-container -->

<include file="Public/footerjs"/>
<!-- inline scripts related to this page -->
<script src="__PUBLIC__/qwadmin/js/date-time/bootstrap-datepicker.js"></script>
<script type="text/javascript">
    jQuery(function ($) {
        $('#birthday').datepicker({
            format: 'yyyy-mm-dd',
            weekStart: 1,
            autoclose: true,
            todayBtn: 'linked',
            language: 'cn'
        });
    });
    
    $(function () {
        $("#tabs").tabs();
        var editor = KindEditor.create('textarea[name="content"]', {
            uploadJson: '__PUBLIC__/kindeditor/php/upload_json.php',
            fileManagerJson: '__PUBLIC__/kindeditor/php/file_manager_json.php',
            allowFileManager: true,
            afterBlur: function () {
                this.sync();
            }
        });
    });

    var lng='';
    var lat='';
    //地图
    var map = new BMap.Map("allmap");
            var point = new BMap.Point(113.631349,34.753488);
            map.centerAndZoom(point,11);
    //地图缩放      
            map.enableScrollWheelZoom(true);
    // 左上角，添加比例尺        
            var top_left_control = new BMap.ScaleControl({
                anchor : BMAP_ANCHOR_TOP_LEFT
            });
    //左上角，添加默认缩放平移控件
            map.addControl(top_left_control);
            var top_left_navigation = new BMap.NavigationControl(); 
            map.addControl(top_left_navigation);
    //清除地图上所有覆盖物
            map.clearOverlays();

            
    // 百度地图API功能
        function theLocation(){
            var city = $("#city").find("option:selected").text();
            var dist = $("#dist").find("option:selected").text();
            var com = $('#com').val();
            var address = $('#address').val();
            console.log(city+dist+com+address);
            if(city != ""){
                map.centerAndZoom(city+dist,11);      // 用城市名设置地图中心点
            }
        }
        function theLocationCom(){
            $("#address").val('');
            var city = $("#city").find("option:selected").text();
            var com = $('#com').val();
            if(com != ""){
                var local = new BMap.LocalSearch(map, {
                    pageCapacity: 1,
                });
                local.setSearchCompleteCallback(function (searchResult) {
            　　　　try{
                    var poi = searchResult.getPoi(0);
                        lng =poi.point.lng;
                        lat =poi.point.lat;
                        console.log(lng,lat);
                        $('#lng').val(lng);
                        $('#lat').val(lat);
                        console.log(poi);
                    map.clearOverlays();
                    map.centerAndZoom(poi.point, 18);
                    
                    var marker = new BMap.Marker(poi.point);
            　　　　    map.addOverlay(marker);　    
            　　　　    marker.enableDragging();
            　　　　    marker.addEventListener("dragend", function(e){
                        lng =e.point.lng;
                        lat =e.point.lat;
                        $('#lng').val(lng);
                        $('#lat').val(lat);
                        console.log(lng,lat);
                        console.log(e);
                  }); 
                    $("#address").val(poi.address);
                }catch (ex) {
                    
                    }
            　　});
                local.search(com);     // 用小区名设置地图中心点
            }
        }
        
    //地图结束

        $(function () {
           var prov = "{$member['prov']}";
           $.ajax({
                type:'post',
                url:"{:U('getAreaInfo')}",
                async:false,
                data:'prov',
                dateType:'json',
                success:function(data){
                    var data = eval('('+data+')');
                    var str = '<option value="" selected >-请选择-</option>';
                    if(data.status == 1){
                        for (var i in data.data){   
                            if(prov == data.data[i]['id']){

                                str=str+'<option selected="selected" value="'+data.data[i]['id']+'">'+data.data[i]['name']+'</option>';
                            }else{
                                str=str+'<option value="'+data.data[i]['id']+'">'+data.data[i]['name']+'</option>';
                            }
                        }
                        $("#prov").html(str);
                        $("#dist").html('<option value="" selected >-请选择-</option>');
                    }
                }
                
            });
        })
        /* 提交  确认添加 */
         /* $("#addList").click(function() {  */
             function addList(){ 
                var a = $("#prov").find("option:selected").text();
                var a1 = $("#prov").val();
                var b = $("#city").find("option:selected").text();
                var b1 = $("#city").val();
                var c = $("#dist").find("option:selected").text();
                var c1 = $("#dist").val();
                var d = $('#com').val();
                var e = $('#address').val();
                var addr = {'prov':a1,'city':b1,'dist':c1,'com':d,'address':e,lng:lng,lat:lat};
                //console.log(addr);
                $.ajax({
                    type:"post",
                    url:"{:U('add1')}",
                    async:false,
                    data:addr,
                    dataType:"json",
                    success:function (data) {                   
                        if (data.status == 1) {
                            alert("添加成功");
                            $("#com").val('');
                            $("#address").val('');
                            //location.reload();
                        } else if(data.status ==0){
                            alert(data.info);
                        } else{
                            alert("参数错误");
                        }
                    }
                });
            }
    $(function(){
         getCity('prov','city')
         getCity('city','dist');
         theLocationCom();
     })
        function getCity(pre,next){
            var pre= $('#'+pre).val();
            var prov = "{$member['prov']}";
            var city = "{$member['city']}";
            var dist = "{$member['dist']}";
            $("#"+next).show();
            $("#dist").html('<option value="" selected ></option>');
            $.ajax({
                type:'post',
                url:"{:U('getAreaInfo')}",
                async:false,
                data:{'pid':pre},
                dateType:'json',
                success:function(data){
                    var data = eval('('+data+')');
                    var str = '<option value="" selected >-请选择-</option>';
                    if(data.status == 1){
                        for (var i in data.data){   
                            if(prov == data.data[i]['id'] || city == data.data[i]['id'] || dist == data.data[i]['id']){

                                str=str+'<option selected="selected" value="'+data.data[i]['id']+'">'+data.data[i]['name']+'</option>';
                            }else{
                                str=str+'<option value="'+data.data[i]['id']+'">'+data.data[i]['name']+'</option>';
                            }
                        }
                        $("#"+next).html(str);
                        
                    }else{
                        $("#"+next).hide();
                        theLocation();
                    }
                }
                
            });
        }
        
    </script>

</body>
</html>
